import { defineStore } from 'pinia';
import { companysData, modulesData } from '@/api/templates/templates';
import { treeList } from '@/api/user/user';
import { store } from '@/store';

export const minxinStore = defineStore('minxin', {
  state: () => ({
    leveList: [], //级别
    typeList: [], //类型
    yearsList: [], //年代
    companyList: [], //单位
    moduleList: [], //单元
  }),
  getters: {
    async getTemplateSelect(e: any) {
      let { data }: any = await companysData(e);
      let DataList: any = await modulesData(e);
      let res: any = await treeList(371994471206981); //级别
      let resData: any = [{ id: -1, text: '全部' }];
      this.leveList = resData.concat(res.data);
      this.moduleList = DataList.data;
      this.companyList = data;
    },
    async getPublicSelect() {
      let res2: any = await treeList(371999507447877); //类型
      let res3: any = await treeList(372051821408325); //年代
      let resData1: any = [{ id: 0, text: '全部' }];
      let resData2: any = [{ id: 1, text: '全部' }];
      this.typeList = resData1.concat(res2.data);
      this.yearsList = resData2.concat(res3.data);
    },
  },
  actions: {},
  persist: true,
});
export function getMinxinStore() {
  return minxinStore(store);
}
